package com.gxcc3.ygps.web.controller.check;

import com.github.pagehelper.PageInfo;
import com.gxcc3.ygps.common.core.controller.BaseController;
import com.gxcc3.ygps.common.core.domain.AjaxResult;
import com.gxcc3.ygps.common.core.domain.BaseEntity;
import com.gxcc3.ygps.common.core.domain.entity.SysCheckDetection;
import com.gxcc3.ygps.common.core.domain.entity.SysCheckGoods;
import com.gxcc3.ygps.common.core.domain.entity.SysCheckGoodsCategory;
import com.gxcc3.ygps.common.core.page.TableDataInfo;
import com.gxcc3.ygps.system.service.ISysCheckGoodsCategoryService;
import com.gxcc3.ygps.system.service.ISysCheckGoodsService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 检测管理 检测列表
 */
@RestController
@RequestMapping("/check/goods")
public class SysCheckGoodsController extends BaseController {


    @Resource
    ISysCheckGoodsService goodsService;

    @Resource
    ISysCheckGoodsCategoryService goodsCategoryService;



    @GetMapping("/categoryTree")
    @PreAuthorize("@ss.hasPermi('check:goods:list')")
    public AjaxResult categoryTree(){
        List<SysCheckGoodsCategory> list = goodsCategoryService.selectGoodsCategoryList();
        return AjaxResult.success(goodsCategoryService.buildGoodsCategoryTree(list));
    }

    /**
     * 查询商品列表
     */
    @PreAuthorize("@ss.hasPermi('check:goods:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysCheckGoods goods)
    {
        startPage();
        List<SysCheckDetection> list = goodsService.selectGoodsList(goods);
        return getDataTable(list);
    }
}
